//递归
function fc1(n) {
  if (n === 0 || n === 1) return 1;
  return fc1(n - 2) + fc1(n - 1);
}

function fc2(n) {
  if (n < 2) return 1;
  if (n === 2) return 2;

  let pre1 = 1;
  let pre2 = 1;
  let current = 2;

  for (let i = 3; i <= n; i++) {
    pre1 = pre2;
    pre2 = current;
    current = pre1 + pre2;
  }

  return current;
}

// console.log(fc2(6));
// 1, 1, 2, 3, 5, 8, 13;

function fcc1(n) {
  if (n === 1) return [1];
  else if (n === 2) return [1, 1];
  else {
    let arr = [1, 1];
    for (let i = 2; i < n; i++) {
      arr.push(arr[i - 2] + arr[i - 1]);
    }
    return arr;
  }
}

console.log(fcc1(5));
